package com.leetcode.merci.lc566;

/**
 * Created by bowen on 2017/7/24.
 */
public class Solution {
    public int[][] matrixReshape(int[][] nums, int r, int c) {
        int w=nums.length;
        int l=nums[0].length;
        int m=0;
        int n=0;
        int[][] result=new int[r][c];
        if(w*l<r*c){
            return nums;
        }
        else {
            for(int i=0;i<w;i++){
                for(int j=0;j<l;j++){
                    result[m][n]=nums[i][j];
                    n++;
                    if(n==c){
                        n=0;
                        m++;
                        continue;
                    }
                }
            }
            return result;
        }
    }

}